Repository navigation
feat(mcpx): supervised stdio by default + adopt-or-reap + restart through supervisor (#9963) - #10767
Conversation
…ough supervisor (#9963) Phase 3 of #1384 (issue #9963), on top of Phase 2 attach (#9962): - Supervised is now a *bool; parse materializes the default (true) for stdio servers in file-loaded configs, with supervised:false as the opt-out into the legacy direct-spawn path. Aliases inherit only the supervised bit from their target (per-view extras like excludeTools stay the alias's own). SupervisedEnabled reads the resolved value; programmatically built configs keep Phase 1 explicit opt-in. - Supervisor protocol gains restart and terminate actions. RestartSupervised has the supervisor kill and respawn its child and attaches the requester to the new child; Pool.Restart uses it for supervised pools with no busy instances. Terminate is the reap mechanism: it refuses while a daemon is attached. - Adopt-or-reap scan (mcpclient.ScanSupervisorSockets): at daemon startup, configured supervisors are left for the Phase 2 adoption scan, orphaned supervisors are reaped with the reap logged, refusals are logged and left in place, stale socket files are removed. Registry.ReapOrphanedSupervisors wires it into Listen. - A protocol-version refusal during adoption is recorded as the pool's last error, so mcpx status names it (with mcpclient.IsProtocolRefusal classifying both refusal spellings). - Test binaries that dial stdio through pools (pool, daemon) handle the supervisor re-exec via testsupport.SuperviseReExec: without it the re-exec runs the whole suite as the supervisor. Tests: config default + opt-out, pool fresh-daemon acceptance (default config acquires supervised, socket present), adoption refusal surfacing in Status().LastError, restart changes the child PID and keeps working, terminate reaps the child and removes the socket, scan adopt/reap/stale branches, protocol refusal classification. Suites green: config, mcpclient, pool, daemon, buildcheck, testsupport; e2e supervised takeover test passes. Darwin (#237): all four affected test packages now cross-compile for darwin/arm64 (go vet GOOS=darwin), but the package.nix darwinSkip runtime list is unchanged in this PR: shrinking it needs a darwin runner to verify the takeover tests actually pass there, which this change does not have. Recorded on #9963.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
agent-note:v1 Codex gate disposition: the Codex review run on this PR failed on Codex usage limits ("You have reached your Codex usage limits for code reviews") and produced no findings — |
Summary
Phase 3 of epic #1384 (issue #9963), on top of Phase 2 attach (#9962, PR #10719):
Extras.Supervisedis now a*bool;parsematerializes the default (true) for stdio servers in file-loaded configs, and"supervised": falseis the opt-out into the legacy direct-spawn path. Aliases inherit only the supervised bit from their target — per-view extras (e.g.excludeTools) stay the alias's own.SupervisedEnabled()reads the resolved value; programmatically built configs keep the Phase 1 explicit opt-in.restartandterminatehandshake actions.RestartSupervisedhas the supervisor kill and respawn its child and attaches the requester to the new child (new PID; supervisor and socket survive).Pool.Restartuses it for supervised pools with no busy instances; busy instances keep the generic drain path.mcpclient.ScanSupervisorSocketsruns at daemon startup (viaRegistry.ReapOrphanedSupervisors, after the Phase 2 adoption scan): configured supervisors are left for adoption, orphaned supervisors are reaped via the terminate action with the reap logged, refusals (attached / version mismatch) are logged and left in place, stale socket files are removed.mcpx statusnames it;mcpclient.IsProtocolRefusalclassifies both refusal spellings.testsupport.SuperviseReExecis wired into the pool and daemon test mains: with supervised as the default, a suite that dials stdio re-execs its own binary as the supervisor, and without the guard that re-exec runs the whole suite recursively.Acceptance (#9963)
TestDefaultConfigStdioRunsSupervised(load file → resolve → acquire → supervisor socket + child PID), plusTestSupervisedDefaultsOnForStdioFromFilefor the opt-out.TestScanSupervisorSocketsAdoptAndReap(configured/adopt, orphan reap with log, stale removal).TestAdoptProtocolRefusalSurfacesInStatus+TestSupervisorProtocolRefusalIsClassified.go vetwithGOOS=darwin, verified), but unskipping the takeover tests needs a darwin runner to prove they pass at runtime; this lane has no darwin machine. Recorded on mcpx: Phase 3 of #1384 — supervised stdio by default + lifecycle hygiene #9963 as the remaining item.Tests
On the laptop, against this branch (rebased on current main):
go test ./internal/config/ ./internal/mcpclient/ ./internal/pool/ ./internal/daemon/ ./internal/buildcheck/ ./internal/testsupport/— all pass.go test ./internal/e2e/ -run TestTakeoverAttachesToSupervisedChild— passes.TestSupervisedRestartThroughSupervisor), terminate reaps the child and removes the socket (TestSupervisedTerminateReapsChild).Task 17484, lane any-d.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.